/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gob.inamhi.entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author dhinojosa
 */
@Entity
@Table(name = "esma", schema="administrative")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Esma.findAll", query = "SELECT e FROM Esma e"),
    @NamedQuery(name = "Esma.findByEsmaId", query = "SELECT e FROM Esma e WHERE e.esmaId = :esmaId"),
    @NamedQuery(name = "Esma.findByEsmanomb", query = "SELECT e FROM Esma e WHERE e.esmanomb = :esmanomb")})
public class Esma implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "esma__id")
    private Integer esmaId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "esmanomb")
    private String esmanomb;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "esmaId")
    private Collection<Cain> cainCollection;

    public Esma() {
    }

    public Esma(Integer esmaId) {
        this.esmaId = esmaId;
    }

    public Esma(Integer esmaId, String esmanomb) {
        this.esmaId = esmaId;
        this.esmanomb = esmanomb;
    }

    public Integer getEsmaId() {
        return esmaId;
    }

    public void setEsmaId(Integer esmaId) {
        this.esmaId = esmaId;
    }

    public String getEsmanomb() {
        return esmanomb;
    }

    public void setEsmanomb(String esmanomb) {
        this.esmanomb = esmanomb;
    }

    @XmlTransient
    public Collection<Cain> getCainCollection() {
        return cainCollection;
    }

    public void setCainCollection(Collection<Cain> cainCollection) {
        this.cainCollection = cainCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (esmaId != null ? esmaId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Esma)) {
            return false;
        }
        Esma other = (Esma) object;
        if ((this.esmaId == null && other.esmaId != null) || (this.esmaId != null && !this.esmaId.equals(other.esmaId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gob.inamhi.entidades.Esma[ esmaId=" + esmaId + " ]";
    }
    
}
